import Mock from "mockjs";
import qs from "qs";

export default () => {
  // 用户登录
  // Mock.mock(/\/login/, config => {
  //   const {user, pwd} = qs.parse(config.body);
  //   if (user === "admin" && pwd === "wasd@007") {
  //     return {
  //       data: {
  //         user_id: Mock.mock("@guid"),
  //         auth_token: Mock.mock("@guid"),
  //         real_name: "Admin"
  //       },
  //       error: {
  //         code: 0,
  //         msg: "Login success"
  //       }
  //     };
  //   }
  //   return {
  //     error: {
  //       code: 4000,
  //       msg: "Your account username or password is incorrect"
  //     }
  //   };
  // });

  // 菜单获取
  Mock.mock(/\/menu/, {
    code:0,
    data: [
      {
        path: "/",
        name: "首页",
        icon: "md-speedometer",
        compName: "Dashboard",
        compPath: "/dashboard"
      },
      {
        path: "/test",
        name: "配置",
        icon: "md-document",
        compName: "Test",
        compPath: "/Test"
      },
      {
        path: "/journal",
        name: "日志信息",
        icon: "md-clipboard",
        children: [
          {
            path: "/journal/qudou",
            name: "趣豆",
            icon: "md-ionitron",
            compName: "Qudou",
            compPath: "/journal/qudou"
          },
            {
                path: "/journal/huoyuedu",
                name: "活跃度",
                icon: "md-trending-up",
                compName: "Huoyudu",
                compPath: "/journal/huoyuedu"
            },
            {
                path: "/journal/renwubao",
                name: "任务包",
                icon: "md-list-box",
                compName: "Renwubao",
                compPath: "/journal/renwubao"
            }
        ]
      },
      {
        path: "/manage",
        name: "用户管理",
        icon: "md-people",
        children: [
          {
            path: "/manage/users",
            name: "用户",
            icon: "md-people",
            compName: "Users",
            compPath: "/manage/users"
          },
            {
                path: "/manage/system",
                name: "管理员",
                icon: "md-contact",
                compName: "System",
                compPath: "/manage/system"
            }
        ]
      },
        {
            path: "/video",
            name: "短视频",
            icon: "ios-camera",
            children: [
                {
                    path: "/video/UploadVideo",
                    name: "视频管理",
                    icon: "md-film",
                    compName: "UploadVideo",
                    compPath: "/video/UploadVideo"
                }
            ]
        },
    ],
    message:""
  });

  // 密码修改
  Mock.mock(/\/edit-password/, config => {
    const {currentPassword} = qs.parse(config.body);
    if (currentPassword === "wasd@007") {
      return {
        error: {
          code: 0,
          msg: "Edit password success"
        }
      };
    }
    return {
      error: {
        code: 4000,
        msg: "Your current password is incorrect"
      }
    };
  });
};
